package com.wzcl.app.dao.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * @author beingven
 * @Description 作文课章节表
 * @createTime 2020年12月20日 13:53:00
 */
@Getter
@Setter
@Entity
@Table(name = "essay_course_catalog")
@DynamicUpdate
@DynamicInsert
@JsonIgnoreProperties({"course"})
public class EssayCourseCatalog implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @ApiModelProperty("课程章节封面图")
    private String image;

    @ApiModelProperty("课程章节主标题")
    private String mainTitle;

    @ApiModelProperty("课程章节副标题")
    private String transcriptTitle;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiModelProperty("课程章节开始时间")
    private Date beginTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiModelProperty("课程章节创建时间")
    private Date createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiModelProperty("课程章节更新时间")
    private Date updateTime;

    @ApiModelProperty("星期几开始")
    private String week;

    @ApiModelProperty("课程顺序权重，表示第几节课")
    private Integer whichLesson;

    @ApiModelProperty("课程表与章节表关联")
    @ManyToOne(cascade = {CascadeType.MERGE, CascadeType.REFRESH},
            fetch = FetchType.EAGER, optional = false)
    @JoinColumn(name = "course_id")
    private Course course;

    @OneToOne
    @JoinColumn(name = "method_base_id")
    @ApiModelProperty("课程章节与写作锦囊关联")
    private WritingMethodBase writingMethodBase;

    @Transient
    @ApiModelProperty("写作锦囊")
    private List<String> writingMethodBases;

    @ApiModelProperty("章节任务")
    @OneToMany(mappedBy = "essayCourseCatalog", fetch=FetchType.EAGER, cascade=CascadeType.ALL)
    private List<CatalogTask> catalogTaskList;
}